<template>
  <div>
    <SearchContainer @search="getData" @reset="() => formRef.resetFields()">
      <a-form ref="formRef" class="form-style-flex" :model="formState" :label-col="{ style: { width: '80px' } }">
        <a-form-item name="dateRange" label="出院日期" class="w-80">
          <a-range-picker v-model:value="formState.dateRange" format="YYYY-MM-DD" value-format="YYYY-MM-DD" />
        </a-form-item>
      </a-form>
    </SearchContainer>
    <a-card class="mt-2">
      <div class="flex justify-start mb-2">
        <BaseExport type="病案上报" :name="'N041_' + projectName" code="000763" file-type="csv" :search-params="formState">导出HN041上报</BaseExport>
      </div>
      <BaseTable fill :data-source="tableData" :loading="loading" :scroll="{ x: 2400 }" column-code="000763" :pagination="pagination">
        <template #bodyCell="{ column, index }">
          <template v-if="column.dataIndex === 'xh'">
            {{ index + 1 }}
          </template>
          <!-- <template v-if="column.dataIndex === 'jhzt'">
            <a-tag v-if="record.jhzt === 0" color="green">待确认</a-tag>
            <a-tag v-if="record.jhzt === 1" color="blue">已确认</a-tag>
            <a-tag v-if="record.jhzt === 2" color="red">已作废</a-tag>
          </template> -->
        </template>
      </BaseTable>
    </a-card>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import dayjs from 'dayjs'
import SearchContainer from '@/components/SearchContainer'
import { getSystemConfig } from '@/utils/systemConfig'

const formRef = ref(null)
const projectName = ref(null)
const formState = ref({
  dateRange: [dayjs().subtract(7, 'day').format('YYYY-MM-DD'), dayjs().format('YYYY-MM-DD')]
})

const { loading, pagination, tableData, getData } = useTable({
  url: '/med/MedicalRecord/getMedicalRecordReportpageList',
  immediate: true,
  params: formState.value,
  formatParams: (params) => {
    return {
      ...params,
      cystdate: params.dateRange[0],
      cyeddate: params.dateRange[1]
    }
  }
})

onMounted(() => {
  projectName.value = getSystemConfig('HOSPITAL_ORGNIZATION_NAME')
})
</script>
